//
//  jinqijingbanViewController.m
//  shuilijuOASystem
//
//  Created by michael on 16/6/17.
//  Copyright © 2016年 czd. All rights reserved.
//
#import "chaxunjinqi.h"

#import "jinqijingbanViewController.h"
#import "overworkingViewController.h"

@interface jinqijingbanViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)NSArray* array;

@end

@implementation jinqijingbanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
     _tableView  = [[UITableView alloc]initWithFrame:CGRectMake(0,0, KScreenWidth, KScreenHeight) style:UITableViewStylePlain];
     _tableView.delegate = self;
    _tableView.dataSource = self;
[self setRightItem];
    [self.view addSubview:_tableView];
    self.title = @"近期经办";
_array = [NSArray arrayWithObjects:@"已办发文(已归档)",@"已办发文(流转中)",@"已办收文(已归档)",@"已办收文(流转中)",nil];
 self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
   UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;

    
    // Do any additional setup after loading the view.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
return 4;
}
-(void)setRightItem{
            UIBarButtonItem * rightIem = [[UIBarButtonItem alloc] initWithTitle:@"搜索" style:UIBarButtonItemStylePlain target:self action:@selector(searchAction)];
        self.navigationItem.rightBarButtonItem = rightIem;
   
    
}
#pragma mark 搜素
-(void)searchAction{
    
    [UIAlertView showWithTitle:@"搜索" message:nil style:UIAlertViewStylePlainTextInput cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
        [self.view endEditing:YES];
        
        if (buttonIndex == 1) {
            UITextField * textField = [alertView textFieldAtIndex:0];
            if (textField.text.length !=0) {
                  UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
 overworkingViewController *overvc = (overworkingViewController *)[storyBoard instantiateViewControllerWithIdentifier:@"over"];
 
                 overvc.url =exchSearch;
    overvc.method =@"handSearch";
    overvc.text =textField.text;
    overvc.isSearching = YES;
     [self.navigationController pushViewController:overvc animated:YES];

                           }
            
        }
        
    }];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]init];
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 40, 40)];
    image.image = [UIImage imageNamed: _array[indexPath.row]];
[cell.contentView addSubview:image];
//    cell.imageView.image = [UIImage imageNamed: _array[indexPath.row]];
    cell.imageView.size = CGSizeMake(30 ,30);
    UILabel *textLabel = [[UILabel alloc]init];
    textLabel.frame = CGRectMake(image.right+10, 5, 200, 60);
    textLabel.text = _array[indexPath.row];
    [cell.contentView addSubview:textLabel];
   

    
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
      UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
 overworkingViewController *overvc = (overworkingViewController *)[storyBoard instantiateViewControllerWithIdentifier:@"over"];
 if (indexPath.row==0) {
    overvc.url=exchrecent;
    overvc.method =@"toArchiveFwPage";
}
else if (indexPath.row==1) {
    overvc.url =exchrecent;
    overvc.method =@"toybFwPage";
}
else if (indexPath.row==2) {
    overvc.url =exchrecent;
    overvc.method =@"toArchiveSwPage";
}
else if (indexPath.row==3) {
    overvc.url =exchrecent;
    overvc.method =@"toybSwPage";
}
 
 overvc.string = _array[indexPath.row];
 [self.navigationController pushViewController:overvc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
